package
{
	import com.kitchen.AbstractNpc;
	import com.kitchen.ClassLoader;
	import com.kitchen.KitchenEvent;
	import com.kitchen.http.ShoperProxy;
	import com.kitchen.model.Vo.AccountVo;
	import com.kitchen.npc.NpcContainer;
	import com.kitchen.ui.controls.start.BusyButton;
	import com.kitchen.ui.dialog.decorate.DecorateDialog;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.text.TextField;

	public class Test extends Sprite
	{
		[Embed (source="images/main.png")]
		private var xmap:Class;
		[Embed (source="images/dialog.png")]
		private var ymap:Class;
		private var mainSkin:BitmapData;
		private var dialogSkin:BitmapData;
		private var account:AccountVo;
		private var tf:TextField;
		public function Test()
		{
			super();
			tf = new TextField();
			tf.text = 'hellow';
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			this.stage.align = StageAlign.TOP;
			var mmap:Bitmap = (new xmap()) as Bitmap;
			this.mainSkin = mmap.bitmapData;
			var dmap:Bitmap = (new ymap()) as Bitmap;
			this.dialogSkin = dmap.bitmapData;
			this.account = new AccountVo('bewell@foxmail.com', '哈根达斯', 'http://www.meichu.com/static/images/50.jpg', 123, 56, 67, 234, 321, 123);
			this.layout();
			//this.addChild(tf);
		}
		
		private function layout():void{
			/*
			var classLoad:ClassLoader = new ClassLoader('/static/kitchen/libs/hatboy.swf', 'com.kitchen.npc.HatBoy');
			classLoad.addEventListener(ClassLoader.LOADED_OK, loadedHandler);
			classLoad.addEventListener(ClassLoader.LOADED_ERROR, loadedHandler);
			/*
			var boy:Boy = new Boy();
			boy.y = 100;
			this.addChild(boy);
			boy.setConfig({'wait':110, 'name':'东郭先生', 'pace':5, 'tox':500});
			boy.goAhead();
			/*
			var wc:WallContainer = new WallContainer(779, 248);
			wc.append({
				'id':30,
				'nCrTime':1321005709,
				'nDid':1,
				'nExpTime':0,
				'nPosit':1,
				'nPx':60,
				'nPy':80,
				'nPz':0,
				'nShopId':131,
				'nStatus':2,
				'nUid':1,
				'nUseTime':0,
				'sName':'沙发',
				'sUrl':'/static/kitchen/deco/zx03_q_msj.png'
			});
			wc.append({
				'id':29,
				'nCrTime':1321005709,
				'nDid':1,
				'nExpTime':0,
				'nPosit':2,
				'nPx':60,
				'nPy':80,
				'nPz':0,
				'nShopId':131,
				'nStatus':2,
				'nUid':1,
				'nUseTime':0,
				'sName':'沙发',
				'sUrl':'/static/kitchen/props/agreement_card.png'
			});
			this.addChild(wc);
			var floor:FloorContainer = new FloorContainer(779, 100);
			floor.append({
				'id':30,
				'nCrTime':1321005709,
				'nDid':1,
				'nExpTime':0,
				'nPosit':3,
				'nPx':60,
				'nPy':80,
				'nPz':0,
				'nShopId':131,
				'nStatus':2,
				'nUid':1,
				'nUseTime':0,
				'sName':'沙发',
				'sUrl':'/static/kitchen/deco/zx05_d_msj.png'
			});
			floor.append({
				'id':30,
				'nCrTime':1321005709,
				'nDid':1,
				'nExpTime':0,
				'nPosit':4,
				'nPx':60,
				'nPy':80,
				'nPz':0,
				'nShopId':131,
				'nStatus':2,
				'nUid':1,
				'nUseTime':0,
				'sName':'沙发',
				'sUrl':'/static/kitchen/props/agreement_card.png'
			});
			floor.y = 272;
			floor.x = 0;
			this.addChild(floor);
			var conter:CounterContainer = new CounterContainer(779, 289);
			conter.append({
				'id':30,
				'nCrTime':1321005709,
				'nDid':1,
				'nExpTime':0,
				'nPosit':6,
				'nPx':60,
				'nPy':80,
				'nPz':0,
				'nShopId':131,
				'nStatus':2,
				'nUid':1,
				'nUseTime':0,
				'sName':'沙发',
				'sUrl':'/static/kitchen/deco/zx14_t_msj.png'
			});
			this.addChild(conter);
			/*
			var bg:BackGround = new BackGround(779, 664);
			bg.setBgImage('/static/kitchen/deco/zx11_d_msj.png');
			this.addChild(bg);
			*/
			/*
			var shopDialog:ShopDialog = new ShopDialog(this.mainSkin, this.dialogSkin);
			this.addChild(shopDialog);
			shopDialog.show({});
			*/
			/*
			var cell:StorageGrid = new StorageGrid(this.dialogSkin, 5, 7);
			this.addChild(cell);
			cell.goPage(2);
			/*
			var task:LeaveWordsDialog = new LeaveWordsDialog(this.mainSkin, this.dialogSkin,{'nGold':1000, 'sUname':'singal'});
			this.addChild(task);
			task.show({});
			/*
			var shoperProxy:ShoperProxy = new ShoperProxy();
			shoperProxy.addEventListener(Proxy.E_OK, succHandle);
			shoperProxy.addEventListener(Proxy.E_CERROR, errorHandle);
			shoperProxy.addEventListener(Proxy.E_SERROR, errorHandle);
			shoperProxy.getShoper('1');
			
			/*
			var rl:ProcessLoading = new ProcessLoading(400, 30);
			rl.setProcess(0.2, '加载历史');
			this.addChild(rl);
			*/
			
			var decorate:DecorateDialog = new DecorateDialog(this.mainSkin, this.dialogSkin, this.account);
			this.addChild(decorate);
			decorate.show({});
			decorate.addEventListener(KitchenEvent.DECO_TEST, decoTestHandler);
			
			/*
			
			var shop:ShopDialog = new ShopDialog(this.mainSkin, this.dialogSkin, this.account);
			this.addChild(shop);
			shop.show({});
			*/
			/*
			var storage:StorageDialog = new StorageDialog(this.mainSkin, this.dialogSkin, {'nGold':1000});
			this.addChild(storage);
			storage.show({});
			*/
			/*
			var task:TaskDialog = new TaskDialog(this.mainSkin, this.dialogSkin, this.account);
			this.addChild(task);
			task.show({});
			var sett:SettingBar = new SettingBar(this.mainSkin, this.account);
			this.addChild(sett);
			
			var acc:AccountBar = new AccountBar(this.mainSkin, this.account);
			this.addChild(acc);
			
			var stock:StockBar = new StockBar(this.mainSkin, this.account);
			this.addChild(stock);
			
			trace('test');
			var star:StartBar = new StartBar(this.mainSkin, this.account);
			star.showGuest(100);
			this.addChild(star);
			
			var friend:FriendsBar = new FriendsBar(this.mainSkin, this.account);
			this.addChild(friend);
			
			var bg:List = new List(this.mainSkin, this.account);
			this.addChild(bg);
			*/
			//return;
			/*
			var fr:List = new List(this.mainSkin, this.dialogSkin, this.account);
			this.addChild(fr);
			return;
			
			var vscroll:VerticalScrollBar = new VerticalScrollBar(200, this.mainSkin);
			vscroll.addEventListener(KitchenEvent.SCROLL, scrollHandle);
			this.addChild(vscroll);
			return;
			var btn:AbstractButton = AbstractButton(new ScrollButton(this.mainSkin));
			this.addChild(btn);
			*/
		}
		
		//
		private function loadedHandler(event:Event):void{
			var cln:Class = event.target.result as Class;
			var boy:AbstractNpc = AbstractNpc(new cln());
			boy.y = 50;
			this.addChild(boy);
			boy.setConfig({'wait':110, 'name':'东郭先生', 'pace':5, 'tox':500});
			boy.goAhead();
			var boy1:AbstractNpc = AbstractNpc(new cln());
			boy1.y = 260;
			this.addChild(boy1);
			boy1.setConfig({'wait':60, 'name':'东郭先生', 'pace':10, 'tox':600});
			boy1.goAhead();
			var boy2:AbstractNpc = AbstractNpc(new cln());
			boy2.y = 400;
			this.addChild(boy2);
			boy2.setConfig({'wait':20, 'name':'东郭先生', 'pace':1, 'tox':700});
			boy2.goAhead();
		}
		
		private function succHandle(event:Event):void{
			trace('ok');
			var shoper:ShoperProxy = ShoperProxy(event.target);
			this.tf.text = 'aaa'+shoper.result.result.shoper.sUname;
		}
		
		private function errorHandle(event:Event):void{
			trace('error');
		}
		
		private function scrollHandle(ke:KitchenEvent):void{
			
		}
		
		private function decoTestHandler(event:Event):void{
			trace('test');
		}
		
	}
}